{include file="public/nheader"}
<div class="layui-fluid layui-bg-white">
    <form action="{:url()}" class="layui-form layui-form-fixed">
        <div class="layui-form-item" id="eclaiyuan">
            <label class="layui-form-label">
                <font color="red">* </font>品牌开关
            </label>
            <div class="layui-input-block">
                <select name="status" lay-verify="">
                    <option value="1" {if !empty($row['status']) && $row['status']==1}selected{/if}>
                        开启品牌
                    </option>
                    <option value="2" {if !empty($row['status']) && $row['status']==2}selected{/if}>
                        关闭品牌
                    </option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>品牌名称
            </label>
            <div class="layui-input-block">
                <input type="text" id="pinpai" name="pinpai" value="{$row.pinpai|default=''}" required=""
                    lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" id="eclaiyuan">
            <label class="layui-form-label">
                <font color="red">* </font>品牌类目
            </label>
            <div class="layui-input-block">
                <select name="category" lay-verify="">
                    <option value="">品牌类目</option>
                    {foreach $category as $k => $v}
                    <option value="{$k}" {if !empty($row['category']) && $row['category']==$k}selected{/if}>
                        {$v}
                        {/foreach}
                    </option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>EC-cid(请慎重修改)
            </label>
            <div class="layui-input-block">
                <input type="text" id="cid" name="cid" value="{$row.cid|default=''}" required="" lay-verify="required"
                    autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>EC-appId(请慎重修改)
            </label>
            <div class="layui-input-block">
                <input type="text" id="appId" name="appId" value="{$row.appId|default=''}" required=""
                    lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>EC-appSecret(请慎重修改)
            </label>
            <div class="layui-input-block">
                <input type="text" id="appSecret" name="appSecret" value="{$row.appSecret|default=''}" required=""
                    lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        {if !empty($row['id'])}
        <div class="layui-form-item" id="eclaiyuan">
            <label class="layui-form-label">
                <font color="red">* </font>未知来源默认EC来源(添加品牌后一分钟更新一次)
            </label>
            <div class="layui-input-block">
                <select name="wzly" lay-verify="">
                    <option value="">EC来源</option>
                    {foreach $eclaiyuan as $pai}
                    <option value="{$pai.ecid}" {if !empty($row['wzly']) && $row['wzly']==$pai.ecid}selected{/if}>
                        {$pai.ecname}{if !empty($pai.ecgroupName)}({$pai.ecgroupName}){/if}
                        {/foreach}
                    </option>
                </select>
                <div style="color:red">请确保汇营销规则流转里面有该分类，否则不会自动分配</div>
            </div>
        </div>
        {else}
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>未知来源默认EC来源
            </label>
            <div class="layui-input-block">
                <div style="color:red">默认来源设置需要添加完配置后才能设置</div>
            </div>
        </div>
        {/if}
        <div class="layui-footer layui-form-item layui-center ">
            <input type="hidden" value="{$row.id|default='0'}" name="id" />
            <input type="hidden" value="{$row.type|default='0'}" name="id" />
            <button class="layui-btn" lay-filter="submitIframe" type="button" lay-submit>提交</button>
            <button class="layui-btn layui-btn-primary" type="button" sa-event="closeDialog">取消</button>
        </div>
    </form>
</div>
{include file="public/nfooter"}
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;
        form.on('switch(kags)', function (data) {
            var value = data.value;
            console.log(value, data);
            return false;
        });
        form.on('checkbox(father)', function (data) {
            if (data.elem.checked) {
                $(data.elem).parent().next('div').find('input').prop("checked", true);
                form.render();
            } else {
                $(data.elem).parent().next('div').find('input').prop("checked", false);
                form.render();
            }
        });
    });
</script>